﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TiposComuns.Objectos;

namespace Servidor.Objectos
{
    /// <summary>
    /// Accepting a new friend
    /// </summary>
    [Serializable]
    public class AcceptFriendAction : Action
    {
        #region Attributes
        private NewFriendPost newFriend;        //New friend added
        #endregion

        #region Constructors
        public NewFriendPost Post
        {
            get { return newFriend.Clone(); }
            set { newFriend = value.Clone(); }
        }

        public AcceptFriendAction() { }

        public AcceptFriendAction(IDMsg id, NewFriendPost newFriend)
            : base(id)
        {
            this.newFriend = newFriend.Clone();
        }
        #endregion

        #region Methods
        public override void Execute(User user)
        {
            user.AcceptFriend(this.newFriend);
        }

        public override void RollBack(User user)
        {
            user.RejectFriend(this.newFriend.Requester);
            user.ReceiveFriend(this.newFriend.Requester);            
        }
        #endregion
    }
}
